#include <vector>
#include "vector.hpp"
#include "TestCase.h"

inline int64_t sum_v(STD::vector<int>& v1, STD::vector<int>& v2)
{
	int64_t sum = v1.size() * 2 + v2.size() * 3;
	int64_t z = 1;
	for (auto v : v1)
	{
		sum += v * z++;
	}
	for (auto v : v2)
	{
		sum += v * z++;
	}
	return sum;
}

ADD_CASE(Vector, []()->std::string {
	int const m[3]{};
	STD::vector<int> v1(10000, 10);
	v1.insert(v1.begin(), 1);
	STD::vector<int> v2(m + 0, m + 3);
	v2.resize(12, 44);
	return std::to_string(sum_v(v1, v2));
});

ADD_CASE(VectorAssign, []()->std::string {
	int const m[3]{};
	STD::vector<int> v1;
	STD::vector<int> v2;
	v1.assign(1090, 32);
	v2.assign(1200, 12);
	v2.insert(v2.end(), v1.begin(), v1.end());
	v2.insert(v2.end(), 10000, 20);
	v1.insert(v1.begin() + 2, 1000, 30);
	return std::to_string(sum_v(v1, v2));
});

ADD_CASE(VectorErase, []()->std::string {
	STD::vector<int> v1;
	STD::vector<int> v2;

	for (int i = 0; i < 10000; ++i)
	{
		v1.push_back(i * i);
	}
	for (int i = 0; i < 100 && v1.size() >= 2; ++i)
	{
		v2.push_back(v1.front());
		v2.push_back(v1.back());
		v1.erase(v1.begin());
		v1.pop_back();
	}
	return std::to_string(sum_v(v1, v2));
});

ADD_CASE(VectorIterator, []()->std::string {
	STD::vector<int> v1;
	STD::vector<int> v2;

	for (int i = 0; i < 10000; ++i)
	{
		v1.push_back(i * i);
	}

	for (int i = 0; i < 100; ++i)
	{
		v2.insert(v2.end(), v1.begin() + i, v1.begin() + i + 100);
		v2.insert(v2.end(), v1.end() - 100 - i, v1.end() - i);
		v2.insert(v2.end(), v1.rbegin() + i, v1.rbegin() + i + 100);
	}
	return std::to_string(sum_v(v1, v2));
});
